#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/11/26 17:57|17:57
# @Author  : yangdingyi
# @File    : 杨辉三角 II
# @Software: PyCharm
from typing import List


class Solution:
    def getRow(self, rowIndex: int) -> List[int]:
        """
        O(k)空间复杂度, 时间 O(k^2)
        :param rowIndex:int 行数
        :return:List[int] 第rowIndex行杨辉三角形
        """
        ans = [1]
        n = 1
        for i in range(rowIndex):
            x = 1
            for j in range(1, n):
                x, ans[j] = ans[j], x + ans[j]
            ans.append(1)
            n += 1
        return ans


solve = Solution()

rowIndex = 3
print(rowIndex)
print(solve.getRow(rowIndex))

